<?php 
function http_post_json($url, $jsonStr)
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonStr);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Content-Type: application/json; charset=utf-8',
        'Content-Length: ' . strlen($jsonStr)
    )
        );
    $response = curl_exec($ch);
    var_dump($response);
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);
    
    return array($httpCode, $response);
}
$access_token=getToken();
$url='https://api.weixin.qq.com/cgi-bin/express/business/order/add?access_token='.$access_token;

$openid='ohFb-40Zv6S5tbQpvCHzpjIfUrKo';
$order_id='0123456789011112';
 
 
$orderInfo=array(
    'add_source'=>0,
    'order_id'=> $order_id,
    'openid'=>$openid,
    'delivery_id'=> 'YUNDA',
    'biz_id'=> '2010225552',
    'custom_remark'=> '临时测试',
    'sender'=>array(
        'name'=>'怡丽丝尔',
        'tel'=>'021-39291306',
        'company'=>'ogilvy',
        'post_code'=> '200001',
        'country'=>'中国',
        'province'=>'上海市',
        'city'=>'上海市',
        'area'=>'青浦区',
        'address'=>'胜利路1588号'
    ),
    'receiver'=>array(
       'name'=>'宋先生',
       'mobile'=>'13681737112',
       'country'=>'中国',
       'province'=>'上海',
       'city'=>'上海',
       'area'=>'徐汇区',
       'address'=>'cccc'
    ),
    'shop'=>array(
        'wxa_path'=>'/index/index',
        'img_url'=>'https://elixir.omnimkt.com/elixir07/img/weather/1.jpg',
        'goods_name'=>'aaa&bbb',
        'goods_count'=>1
    ),
    'cargo'=>array(
        'count'=>1,
        'weight'=>1,
        'space_x'=>20,
        'space_y'=>20,
        'space_z'=>20,
        'detail_list'=>array(
            array(
            'name'=>'1018F396000',
            'count'=>1
            ),
            array(
                'name'=>'74366797803',
                'count'=>1
            )
        )
    ),
    'insured'=>array(
        'use_insured'=>0,
        'insured_value'=>0
    ),
    'service'=>array(
        'service_type'=>0,
        'service_name'=>'标准快递'
    )
    
);
 

/**
 {"add_source":0,"order_id":"0123456789011112","openid":"ohFb-40Zv6S5tbQpvCHzpjIfUrKo","delivery_id":"YUNDA","biz_id":"2010225552","custom_remark":"临时测试","sender":{"name":"怡丽丝尔","tel":"021-39291306","company":"ogilvy","post_code":"200001","country":"中国","province":"上海市","city":"上海市","area":"青浦区","address":"胜利路1588号"},"receiver":{"name":"宋先生","mobile":"13681737112","country":"中国","province":"上海","city":"上海","area":"徐汇区","address":"cccc"},"shop":{"wxa_path":"\/index\/index","img_url":"https:\/\/elixir.omnimkt.com\/elixir07\/img\/weather\/1.jpg","goods_name":"aaa&bbb","goods_count":1},"cargo":{"count":1,"weight":1,"space_x":20,"space_y":20,"space_z":20,"detail_list":[{"name":"1018F396000","count":1},{"name":"74366797803","count":1}]},"insured":{"use_insured":0,"insured_value":0},"service":{"service_type":0,"service_name":"标准快递"}}
 
 

string(301) "{"errcode":0,"errmsg":"ok","order_id":"0123456789011112","waybill_id":"3103674248663","waybill_data":[{"key":"YUNDA_PackageCenterCode","value":"上海分拨包"},{"key":"YUNDA_ShortAddr_Part1","value":"300"},{"key":"YUNDA_ShortAddr_Part2","value":"000"}],"is_correct_sender":0,"is_correct_receiver":0}" NULL
 */

 
$jsonInfo=json_encode($orderInfo,  JSON_UNESCAPED_UNICODE);
 
echo $jsonInfo;
echo "<br /><br />"; 
$getdata=json_decode(http_post_json($url, $jsonInfo),true);
var_dump($getdata);